from django.db import models


class Follow(models.Model):
    """关注模型类"""
    user_id = models.IntegerField('用户ID')
    following_id = models.IntegerField('被关注用户ID')

    class Meta:
        db_table = 'follow'


class Like(models.Model):
    """点赞记录模型类"""
    like_type = models.SmallIntegerField('点赞目标类型', choices=((1, '笔记'), (2, '评论'), (3, '解析')))
    user_id = models.IntegerField('用户ID')
    like_id = models.IntegerField('点赞目标ID')

    class Meta:
        db_table = 'like'


class Comment(models.Model):
    """评论模型类"""
    content = models.TextField('评论内容')
    likes_num = models.IntegerField('点赞数', default=0)
    user_id = models.IntegerField('用户ID')
    note_id = models.IntegerField('笔记ID')
    parent_id = models.IntegerField('父级评论ID', default=0)
    create_time = models.DateTimeField('评论时间', auto_now_add=True)

    class Meta:
        db_table = 'comment'


class Favor(models.Model):
    """收藏表模型类"""
    user_id = models.IntegerField('用户ID')
    dir_id = models.IntegerField('收藏夹ID')
    note_id = models.IntegerField('收藏的笔记ID')
    create_time = models.DateTimeField('收藏时间', auto_now_add=True)

    class Meta:
        db_table = 'favor'


class FavorDir(models.Model):
    """收藏夹模型类"""
    title = models.CharField('收藏夹名称', max_length=20)
    user_id = models.IntegerField('用户ID')
    create_time = models.DateTimeField('创建时间', auto_now_add=True)

    class Meta:
        db_table = 'favor_dir'
